using System.Threading.Tasks;
using JoyfulHomeJourney.BackEnd.Infrastructure.Dtos.Requests.Objects;
using JoyfulHomeJourney.BackEnd.Server.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace JoyfulHomeJourney.BackEnd.Api.Admin.Controllers
{
	public class ShiftsController : BaseController
	{
		private readonly IShiftsServer _shiftsServer;
		public ShiftsController(IShiftsServer shiftsServer)
		{
			_shiftsServer = shiftsServer;
		}
		/// <summary>
		/// 添加
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Add(RequestShiftsDto dto)
		{
			return Send(await _shiftsServer.AddAsync(dto));
		}
		/// <summary>
		/// 删除
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Delete(RequestShiftsDto dto)
		{
			return Send(await _shiftsServer.DeleteAsync(dto));
		}
		/// <summary>
		/// 修改
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
        [TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { "employee" })]
        public async Task<IActionResult> Update(RequestShiftsDto dto)
		{
			return Send(await _shiftsServer.UpdateAsync(dto));
		}
        /// <summary>
        /// PC获取所有交班消息
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        [HttpGet]
        [TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { "employee" })]
        public async Task<IActionResult> Pagination(int page,int limit,string key)
		{
			return Send(await _shiftsServer.PaginationAsync(page,limit,key));
		}
	}
}
